package com.bah.tract.service;

public final class PropertyHashAndEquals {

	private PropertyHashAndEquals() {

	}

	public static int hashCode(final Property p) {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((p.dateTimeValue == null) ? 0 : p.dateTimeValue.hashCode());
		result = prime * result
				+ ((p.doubleValue == null) ? 0 : p.doubleValue.hashCode());
		result = prime * result
				+ ((p.longValue == null) ? 0 : p.longValue.hashCode());
		result = prime * result + ((p.name == null) ? 0 : p.name.hashCode());
		result = prime * result
				+ ((p.stringValue == null) ? 0 : p.stringValue.hashCode());
		result = prime * result + ((p.type == null) ? 0 : p.type.hashCode());
		return result;
	}

	public static final boolean equals(final Property p, final Object obj) {
		if (p == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (p.getClass() != obj.getClass()) {
			return false;
		}
		final Property other = (Property) obj;
		if (p.dateTimeValue == null) {
			if (other.dateTimeValue != null) {
				return false;
			}
		} else if (!p.dateTimeValue.equals(other.dateTimeValue)) {
			return false;
		}
		if (p.doubleValue == null) {
			if (other.doubleValue != null) {
				return false;
			}
		} else if (!p.doubleValue.equals(other.doubleValue)) {
			return false;
		}
		if (p.longValue == null) {
			if (other.longValue != null) {
				return false;
			}
		} else if (!p.longValue.equals(other.longValue)) {
			return false;
		}
		if (p.name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!p.name.equals(other.name)) {
			return false;
		}
		if (p.stringValue == null) {
			if (other.stringValue != null) {
				return false;
			}
		} else if (!p.stringValue.equals(other.stringValue)) {
			return false;
		}
		if (p.type != other.type) {
			return false;
		}
		return true;
	}

}
